package iec61850

import "C"

// #include <iec61850_client.h>
import "C"

type FunctionalConstraint int
type MMSType int

const (
	// IEC61850_FC_ST Status information
	IEC61850_FC_ST FunctionalConstraint = iota
	// IEC61850_FC_MX Measurands - analog values
	IEC61850_FC_MX
	// IEC61850_FC_SP Setpoint
	IEC61850_FC_SP
	// IEC61850_FC_SV Substitution
	IEC61850_FC_SV
	// IEC61850_FC_CF Configuration
	IEC61850_FC_CF
	// IEC61850_FC_DC Description
	IEC61850_FC_DC
	// IEC61850_FC_SG Setting group
	IEC61850_FC_SG
	// IEC61850_FC_SE Setting group editable
	IEC61850_FC_SE
	// IEC61850_FC_SR Service response / Service tracking
	IEC61850_FC_SR
	// IEC61850_FC_OR Operate received
	IEC61850_FC_OR
	// IEC61850_FC_BL Blocking
	IEC61850_FC_BL
	// IEC61850_FC_EX Extended definition
	IEC61850_FC_EX
	// IEC61850_FC_CO Control
	IEC61850_FC_CO
	// IEC61850_FC_US Unicast SV
	IEC61850_FC_US
	// IEC61850_FC_MS Multicast SV
	IEC61850_FC_MS
	// IEC61850_FC_RP Unbuffered report
	IEC61850_FC_RP
	// IEC61850_FC_BR Buffered report
	IEC61850_FC_BR
	// IEC61850_FC_LG Log control blocks
	IEC61850_FC_LG
	// IEC61850_FC_GO Goose control blocks
	IEC61850_FC_GO

	// IEC61850_FC_ALL All FCs - wildcard value
	IEC61850_FC_ALL  FunctionalConstraint = 99
	IEC61850_FC_NONE FunctionalConstraint = -1
)

const (
	MMS_ARRAY MMSType = iota
	MMS_STRUCTURE
	MMS_BOOLEAN
	MMS_BIT_STRING
	MMS_INTEGER
	MMS_UNSIGNED
	MMS_FLOAT
	MMS_OCTET_STRING
	MMS_VISIBLE_STRING
	MMS_GENERALIZED_TIME
	MMS_BINARY_TIME
	MMS_BCD
	MMS_OBJ_ID
	MMS_STRING
	MMS_UTC_TIME
	MMS_DATA_ACCESS_ERROR
)

const (
	MMS_NIL = -1
)

// Err get real ied error type
func Err(e C.IedClientError) string {
	switch e {
	case C.IED_ERROR_OK:
		return "IED_ERROR_OK"
	case C.IED_ERROR_NOT_CONNECTED:
		return "IED_ERROR_NOT_CONNECTED"
	case C.IED_ERROR_ALREADY_CONNECTED:
		return "IED_ERROR_ALREADY_CONNECTED"
	case C.IED_ERROR_CONNECTION_LOST:
		return "IED_ERROR_CONNECTION_LOST"
	case C.IED_ERROR_SERVICE_NOT_SUPPORTED:
		return "IED_ERROR_SERVICE_NOT_SUPPORTED"
	case C.IED_ERROR_CONNECTION_REJECTED:
		return "IED_ERROR_CONNECTION_REJECTED"
	case C.IED_ERROR_OUTSTANDING_CALL_LIMIT_REACHED:
		return "IED_ERROR_OUTSTANDING_CALL_LIMIT_REACHED"
	case C.IED_ERROR_USER_PROVIDED_INVALID_ARGUMENT:
		return "IED_ERROR_USER_PROVIDED_INVALID_ARGUMENT"
	case C.IED_ERROR_ENABLE_REPORT_FAILED_DATASET_MISMATCH:
		return "IED_ERROR_ENABLE_REPORT_FAILED_DATASET_MISMATCH"
	case C.IED_ERROR_OBJECT_REFERENCE_INVALID:
		return "IED_ERROR_OBJECT_REFERENCE_INVALID"
	case C.IED_ERROR_UNEXPECTED_VALUE_RECEIVED:
		return "IED_ERROR_UNEXPECTED_VALUE_RECEIVED"
	case C.IED_ERROR_TIMEOUT:
		return "IED_ERROR_TIMEOUT"
	case C.IED_ERROR_ACCESS_DENIED:
		return "IED_ERROR_ACCESS_DENIED"
	case C.IED_ERROR_OBJECT_DOES_NOT_EXIST:
		return "IED_ERROR_OBJECT_DOES_NOT_EXIST"
	case C.IED_ERROR_OBJECT_EXISTS:
		return "IED_ERROR_OBJECT_EXISTS"
	case C.IED_ERROR_OBJECT_ACCESS_UNSUPPORTED:
		return "IED_ERROR_OBJECT_ACCESS_UNSUPPORTED"
	case C.IED_ERROR_TYPE_INCONSISTENT:
		return "IED_ERROR_TYPE_INCONSISTENT"
	case C.IED_ERROR_TEMPORARILY_UNAVAILABLE:
		return "IED_ERROR_TEMPORARILY_UNAVAILABLE"
	case C.IED_ERROR_OBJECT_UNDEFINED:
		return "IED_ERROR_OBJECT_UNDEFINED"
	case C.IED_ERROR_INVALID_ADDRESS:
		return "IED_ERROR_INVALID_ADDRESS"
	case C.IED_ERROR_HARDWARE_FAULT:
		return "IED_ERROR_HARDWARE_FAULT"
	case C.IED_ERROR_TYPE_UNSUPPORTED:
		return "IED_ERROR_TYPE_UNSUPPORTED"
	case C.IED_ERROR_OBJECT_ATTRIBUTE_INCONSISTENT:
		return "IED_ERROR_OBJECT_ATTRIBUTE_INCONSISTENT"
	case C.IED_ERROR_OBJECT_VALUE_INVALID:
		return "IED_ERROR_OBJECT_VALUE_INVALID"
	case C.IED_ERROR_OBJECT_INVALIDATED:
		return "IED_ERROR_OBJECT_INVALIDATED"
	case C.IED_ERROR_MALFORMED_MESSAGE:
		return "IED_ERROR_MALFORMED_MESSAGE"
	case C.IED_ERROR_SERVICE_NOT_IMPLEMENTED:
		return "IED_ERROR_SERVICE_NOT_IMPLEMENTED"
	case C.IED_ERROR_UNKNOWN:
		return "IED_ERROR_UNKNOWN"
	}

	return "IED_ERROR_UNDEFINED"
}
